#!/usr/bin/python3
# ******************************************************************************
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
# licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#     http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# ******************************************************************************/
import json

from elasticsearch import Elasticsearch


class ES(object):
    def __init__(self):
        self.es = Elasticsearch([{'host': '127.0.0.1', 'port': 9200}])
        self.es.indices.put_settings(index='_all', body={'index': {
            'max_result_window': 500000}})

    def create_index(self, name):
        self.es.indices.create(index=name)

    def get_setting(self):
        response = self.es.indices.get_settings(index='_all')
        print(f'settings is {response}')


if __name__ == "__main__":
    obj = ES()
    obj.create_index('test_1')
    obj.get_setting()
